package cn.biplam.back.bean.ddl.sql2db;

import cn.biplam.back.sql.ddl.Table;
import cn.biplam.common.client.DbResource;
import cn.biplam.common.wrapper.ErrorMessage;

public class PKParser {
	
	/**数据源信息*/
	private DbResource mDbResource;
	/**Table对象*/
	private Table mTable;
	
	/**
	 * 功能：构造方法
	 * @param mDbResource
	 * @param mTable
	 */
	public PKParser(DbResource mDbResource,Table mTable){
		this.mDbResource = mDbResource;
		this.mTable = mTable;
	}
	
	/**
	 * 功能   得到主键创建语句
	 * @return
	 */
	public String getCreatePK() throws ErrorMessage {
		
		String sPk = "";
		
		try {
			Sql2DbFactory sf = new Sql2DbFactory(mDbResource,mTable);
			sPk = sf.getPk().toString();
		} catch (Exception e) {
			ErrorMessage mErrorMessage = new ErrorMessage(e);
			throw mErrorMessage;
		}

		return sPk;
	}
	
	/**
	 * 功能   得到主键创建语句
	 * @return
	 */
	public String getDropPK() throws ErrorMessage {
		
		String sPk = "";
		
		try {
			if("1".equals(this.mDbResource.getDbtype())){
				sPk = this.getDropPKOracle();
			}
		} catch (Exception e) {
			ErrorMessage mErrorMessage = new ErrorMessage(e);
			throw mErrorMessage;
		}

		return sPk;
	}
	
	/**
	 * 功能  生成删除主键sql
	 * @return String
	 */
	private String getDropPKOracle() {
		//主键随表一起drop
		return "";
	}
}
